unit Padroes;

interface

uses
  System.SysUtils, System.Classes, Vcl.Controls, Vcl.StdCtrls, System.UITypes,
  Vcl.Graphics, Vcl.Themes, Vcl.Mask;

type
  TOdontoEdit = class(TEdit)
  private
     FCorFoco: TColor;
     procedure setCorFoco(Value: TColor);
     procedure doMudarCorComFoco(Sender: TObject);
     procedure doMudarCorSemFoco(Sender: TObject);
  protected
  public
     constructor Create(AOwner: TComponent); override;
  published
     property CorFoco: TColor read FCorFoco write FCorFoco;
  end;

  TOdontoNumero = class(TMaskEdit)
  private
     FCorFoco: TColor;
     procedure setCorFoco(Value: TColor);
     procedure doMudarCorComFoco(Sender: TObject);
     procedure doMudarCorSemFoco(Sender: TObject);
  protected
  public
     constructor Create(AOwner: TComponent); override;
  published
     property CorFoco: TColor read FCorFoco write FCorFoco;
  end;

  TOdontoLabel = class(TLabel)
  private
  protected
  public
  published
  end;

  TOdontoComboBox = class(TComboBox)
  private
     FCorFoco: TColor;
     procedure setCorFoco(Value: TColor);
     procedure doMudarCorComFoco(Sender: TObject);
     procedure doMudarCorSemFoco(Sender: TObject);
  protected
  public
     constructor Create(AOwner: TComponent); override;
  published
     property CorFoco: TColor read FCorFoco write FCorFoco;
  end;

procedure Register;

implementation

procedure Register;
begin
   RegisterComponents('Odonto', [TOdontoLabel]);
   RegisterComponents('Odonto', [TOdontoEdit]);
   RegisterComponents('Odonto', [TOdontoNumero]);
   RegisterComponents('Odonto', [TOdontoComboBox]);
end;

{ TOdontoEdit }

constructor TOdontoEdit.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   CharCase := ecUpperCase;
   OnEnter := doMudarCorComFoco;
   OnExit := doMudarCorSemFoco;
   CorFoco := $00EBEBEB;
end;

procedure TOdontoEdit.doMudarCorComFoco(Sender: TObject);
begin
   TOdontoEdit(Self).Color := FCorFoco
end;

procedure TOdontoEdit.doMudarCorSemFoco(Sender: TObject);
begin
   TOdontoEdit(Self).Color := clWindow;
end;

procedure TOdontoEdit.setCorFoco(Value: TColor);
begin
   if ( Value <> clWindow ) then
      FCorFoco := Value;
end;

{ TOdontoNumero }

constructor TOdontoNumero.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   CharCase := ecUpperCase;
   OnEnter := doMudarCorComFoco;
   OnExit := doMudarCorSemFoco;
   CorFoco := $00EBEBEB;
   NumbersOnly := True;
end;

procedure TOdontoNumero.doMudarCorComFoco(Sender: TObject);
begin
   TOdontoEdit(Self).Color := FCorFoco
end;

procedure TOdontoNumero.doMudarCorSemFoco(Sender: TObject);
begin
   TOdontoEdit(Self).Color := clWindow;
end;

procedure TOdontoNumero.setCorFoco(Value: TColor);
begin
   if ( Value <> clWindow ) then
      FCorFoco := Value;
end;

{ TOdontoComboBox }

constructor TOdontoComboBox.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   CharCase := ecUpperCase;
   OnEnter := doMudarCorComFoco;
   OnExit := doMudarCorSemFoco;
   CorFoco := $00EBEBEB;
   Style := csDropDownList;
end;

procedure TOdontoComboBox.doMudarCorComFoco(Sender: TObject);
begin
   TOdontoComboBox(Self).Color := FCorFoco
end;

procedure TOdontoComboBox.doMudarCorSemFoco(Sender: TObject);
begin
   TOdontoComboBox(Self).Color := clWindow;
end;

procedure TOdontoComboBox.setCorFoco(Value: TColor);
begin
   if ( Value <> clWindow ) then
      FCorFoco := Value;
end;

end.
